import { type BaseComponent } from '../../base_component.js'; import { type Constructor } from '../../types.js'; /** * A duck-typed slice of Lucid's ModelQueryBuilder — just the one method * `paginate()` actually calls. Avoids a hard dependency on * `@adonisjs/lucid` from this package's public surface; any object * shaped like this (a real Lucid query builder, a hand-rolled one) works. */ export interface Paginatable { paginate(page: number, perPage: number): Promise; } /** * Opt-in trait, applied via `compose(Component, WithPagination)` — not * composed into the base `Component`, matching how PHP Livewire's * `WithPagination` is `use`d only by components that actually paginate. * * Declares a real `page = 1` property (so `Post.paginate(10)`-style * usage works with zero extra setup, matching the official trait's * every example) and the navigation methods (`setPage`/`nextPage`/ * `previousPage`/`resetPage`) plus a `paginate()` helper. * * Query-string sync is NOT automatic, unlike the PHP trait — a mixin * can declare a plain property fine, but it can't reach into a further * subclass and register a `@url()`-style decorator on it (decorators * are only visible on the exact class they're applied to, not * inherited through a mixin's own class — verified empirically, not * assumed). Add `@url()` yourself on top if you want `page` synced to * the address bar: * * ```ts * export default class ShowPosts extends compose(Component, WithPagination) { * @url() * declare page: number * } * ``` */ export declare function WithPagination>(Base: T): { new (...args: any[]): { page: number; /** Jump directly to a page number, floored at 1. */ setPage(page: number, pageName?: string): void; /** Go to the next page. */ nextPage(pageName?: string): void; /** Go to the previous page, floored at 1. */ previousPage(pageName?: string): void; /** Reset the page back to 1 — call from an action that changes a filter/search property. */ resetPage(pageName?: string): void; /** * Wraps Lucid's native `queryBuilder.paginate(page, perPage)` — * pagination logic itself isn't reimplemented here, just the glue * between the component's current page property and the call. * * `pageName` targets a different property than `page` — declare it * yourself (e.g. `invoicesPage = 1`) for a second paginator in the * same component; every method above accepts the same parameter. */ paginate(queryBuilder: Paginatable, perPage?: number, pageName?: string): Promise; "__#170@#id": string; "__#170@#name": string; "__#170@#viewPath": string; "__#170@#view": ReturnType; "__#170@#viewData": Record; "__#170@#router": import("@adonisjs/core/types").HttpRouterService; bindings: any; app: import("@adonisjs/core/types").ApplicationService; ctx: import("@adonisjs/http-server").HttpContext; __setRouter(router: import("@adonisjs/core/types").HttpRouterService): void; __getRouter(): import("@adonisjs/core/types").HttpRouterService; __id: string; __name: string; viewPath: string; view: ReturnType; viewData: Record; setId(id: string): void; getId(): string; setName(name: string): void; setViewPath(view: string): void; getName(): string; render(): Promise; skipRender(html?: string): void; transition(type?: string): void; skipTransition(): void; shouldSkipRender(): boolean; skipMount(): void; skipHydrate(): void; }; } & T;