import Component from "@glimmer/component"; import { RequestLoadingState } from "@warp-drive-mirror/core/reactive"; import { InfinitePaginationContentFeatures, InfinitePaginationState, PageCache, PageHints, PagedPaginationContentFeatures, PagedPaginationState, PagedPaginationState as PagedPaginationState$1, PaginateArgs, PaginateMode, PaginateMode as PaginateMode$1, PaginationCache, PaginationContentFeatures, PaginationContentFeaturesFor, PaginationContentFeaturesFor as PaginationContentFeaturesFor$1, PaginationLink, PaginationLinks, PaginationLinks as PaginationLinks$1, PaginationLinksSubscription, PaginationState, PaginationStateFor, PaginationStateFor as PaginationStateFor$1, PaginationSubscription, PlaceholderPaginationLink, RealPaginationLink, RecoveryFeatures, RelationalPaginationLink, SharedPaginationContentFeatures, SharedPaginationState } from "@warp-drive-mirror/core/signals/-leaked"; import { ComponentLike } from "@glint/template"; import { RequestManager, Store } from "@warp-drive-mirror/core"; import { StructuredErrorDocument } from "@warp-drive-mirror/core/types/request"; //#region src/-private/paginate.d.ts interface EmberPaginateArgs extends PaginateArgs { /** * Which navigation surface the component yields: `'paged'` (the default) or * `'infinite'`. Type-only — it narrows the state and features yielded to the * `content`, `always`, and `default` blocks so the two surfaces cannot be * mixed, and is never read at runtime. */ mode?: M; chrome?: ComponentLike<{ Blocks: { default: []; }; Args: { state: PaginationStateFor$1 | null; features: PaginationContentFeaturesFor$1; }; }>; } interface PaginateSignature { Args: EmberPaginateArgs; Blocks: { /** * The block to render when the component is idle and waiting to be given a request. * */ idle: []; /** * The block to render when the request is loading. * */ loading: [state: RequestLoadingState]; /** * The block to render when the request was cancelled. * */ cancelled: [error: StructuredErrorDocument, features: RecoveryFeatures]; /** * The block to render when the request failed. If this block is not provided, * the error will be rethrown. * * Thus it is required to provide an error block and proper error handling if * you do not want the error to crash the application. * */ error: [error: StructuredErrorDocument, features: RecoveryFeatures]; /** * The block to render when the request succeeded. * */ content: [state: PaginationStateFor$1, features: PaginationContentFeaturesFor$1]; always: [state: PaginationStateFor$1, features: PaginationContentFeaturesFor$1]; /** * The fallback block, rendered when no other named blocks are provided. * Receives the same params as the `content` block. * * When this block is provided, none of the other named blocks will ever * be utilized — providing it signals that request state management will * occur elsewhere, so the block renders regardless of the state of the * initiating request. * */ default: [state: PaginationStateFor$1, features: PaginationContentFeaturesFor$1]; }; } /** * The `` component provides declarative, reactive control-flow for * rendering a paginated collection: it monitors the request that loads the * collection's entry page and yields a pagination state for navigating and * rendering the collection's pages. * * ## Blocks * * Five states, only one of which renders at a time: * * - `idle`: no request to monitor yet. If the component is idle and no idle * block is provided, an error is thrown. * - `loading`: the collection is blocking-loading — only the very first page * load (or the reset to a different collection) enters this state. Receives * the request's `RequestLoadingState` for progress UIs. Navigating with * `loadPage`/`loadNext`/`loadPrev` does not re-enter it; those surface * through the individual page requests instead. * - `cancelled`: the initial request was aborted. Falls through to the `error` * block when no cancelled block is provided; if neither block exists the * cancellation is swallowed. * - `error`: the initial request rejected. If no error block is provided, the * error is rethrown — provide one if the failure should not crash the app. * Both `cancelled` and `error` receive the error and recovery features * (`retry`, `isOnline`, `isHidden`). * - `content`: the collection is ready. Receives the pagination state * (`pages`) and the content features. * * Two additional blocks sit outside the state machine: `always` renders in * every state, and providing a `default` block replaces all named blocks — * it renders regardless of the request's state, for consumers managing * control-flow themselves. Both receive the same params as `content`. * * ## Modes * * The `@mode` arg (`'paged'`, the default, or `'infinite'`) narrows the state * and features yielded to `content`/`always`/`default` to one of the two * navigation surfaces so the APIs cannot be mixed. It is type-only and never * read at runtime. * * **Paged** — render the active page via its request, navigate with `loadPage` * or the links yielded by ``: * * ```gts * import { Request } from '@warp-drive-mirror/ember'; * import { EachLink, Paginate } from '@warp-drive-mirror/ember/experiments'; * * * ``` * * **Infinite** — render the accumulated `data`, grow it with * `loadNext`/`loadPrev`: * * ```gts * * ``` * * ## Shared collection state * * Loaded pages live in a cache shared by every component paginating the same * collection (identified by its `first` — or `self` — link), while each * `` keeps its own local navigation state (active page, loaded * run). The `@pageHints` arg supplies `currentPage`/`totalPages` when the * response does not expose them in the default `meta` locations; because the * hints attach to the shared cache, every component sharing a collection must * pass the same function reference. * * ## Route-driven navigation * * A changed `@request` arg does not tear the component down. The existing * content stays rendered — with `features.isNavigating` set to `true` — while * the new request resolves: a request that resolves to a page of the same * collection is adopted as the new active page (for example the browser back * button changing a `?page=` query param the route turns into a request); one * that resolves to a different collection resets the pagination like a fresh * start. * * ## Request lifecycle * * The content features expose the same `refresh`/`reload` controls as * ``, applied to the collection's initiating request, and the * component accepts the same `@autorefresh`, `@autorefreshThreshold` and * `@autorefreshBehavior` args (see the `` component's * documentation). To manage the lifecycle externally, create the subscription * with `createPaginationSubscription` and pass it via `@subscription` — the * component then uses it instead of creating and disposing its own. * * @since 5.9.0 * @public * @badge Component * @title */ declare class Paginate extends Component> { /** * The store instance to use for making requests. If contexts are available, this * will be the `store` on the context, else it will be the store service. * * @internal */ _store: Store; /** @internal */ get store(): Store | RequestManager; /** @internal */ _state: PaginationSubscription | null; /** @internal */ get state(): PaginationSubscription; /** * The chrome component to use for rendering the request. * * @internal */ get Chrome(): ComponentLike<{ Blocks: { default: []; }; Args: { state: PaginationStateFor$1 | null; features: PaginationContentFeaturesFor$1; }; }>; /** * The pagination state narrowed to the mode's surface for yielding. The cast * is sound: the full state structurally satisfies both surfaces; `M` is just * unresolved inside the class body. * * @internal */ get paginationState(): PaginationStateFor$1; /** * The content features narrowed to the mode's surface for yielding. See * {@link paginationState}. * * @internal */ get contentFeatures(): PaginationContentFeaturesFor$1; willDestroy(): void; } //#endregion //#region src/-private/each-link.d.ts interface EachLinkSignature { Args: { /** * The paged pagination state (yielded by ``) to derive the * navigation links from. */ pages: PagedPaginationState$1; }; Blocks: { /** * Receives the {@link PaginationLinks} for the pagination state: the * numbered `links` (with placeholders for gaps) and the relational * `prev`/`next` links. The consumer renders them — in whatever markup * and order it wants. */ default: [state: Readonly>]; }; } /** * The `` component yields the navigation links for a paginated * collection, derived from the {@link PagedPaginationState} a `` * component yields to its `content` block. * * It renders no markup of its own: it yields a single {@link PaginationLinks} * object, and the consumer decides which links to render, with what markup, * and in what order. * * The yielded state provides: * * - `links` — the numbered links, with {@link PlaceholderPaginationLink} * placeholders standing in for gaps of not-yet-loaded pages. Discriminate * with `isReal`. Empty for cursor-based collections, which have no page * numbers to render. * - `prev` / `next` — the relational links for the active page, or `null` at * the collection's edges. Available in both numbered and cursor-based * pagination, and the only navigation a cursor-based collection has. * - `first` / `last` — the relational links to the collection's edges, when * the response exposes them. Usually present on every page — including the * edge page itself, where the link's `isCurrent` is `true` (useful for * disabling the control). * * Every link exposes `setActive` to load its page and make it the active page * of the pagination state, keeping every component reading that state in sync. * * ```gts * import { Paginate, EachLink } from '@warp-drive-mirror/ember/experiments'; * * * ``` * * Since the links all read from the shared page graph, they update as pages * load and as the active page changes. * * @since 5.9.0 * @public * @badge Component * @title */ declare class EachLink extends Component> { /** @internal */ _state: PaginationLinksSubscription | null; /** @internal */ get state(): PaginationLinksSubscription; willDestroy(): void; } //#endregion export { EachLink, type InfinitePaginationContentFeatures, type InfinitePaginationState, type PageCache, type PageHints, type PagedPaginationContentFeatures, type PagedPaginationState, Paginate, type PaginateMode, type PaginationCache, type PaginationContentFeatures, type PaginationContentFeaturesFor, type PaginationLink, type PaginationLinks, type PaginationState, type PaginationStateFor, type PlaceholderPaginationLink, type RealPaginationLink, type RelationalPaginationLink, type SharedPaginationContentFeatures, type SharedPaginationState }; //# sourceMappingURL=experiments.d.ts.map